
<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop">
          <div style="width:100%;float:left">
              <table style="font-size:12px;" class="table1style">
                  <tr>
                      <td>规则类型</td>
                      <td>
                          <el-select v-model="searchObj.ruletype" clearable>
                              <el-option v-for="(item,index) in ruletypeOption" :key="index" :label="item.label" :value="item.value"></el-option>
                          </el-select>
                      </td>
                      <td>标本类型</td>
                      <td>
                          <rm-ddl-common ref="ddlspecimen" @change="specimenchange" datatype="specimen" dataname="标本类型" v-model="searchObj.specimen" width="150px" :clearable="true" :readonly="true">
                          </rm-ddl-common>
                      </td>
                      <td>细菌</td>
                      <td>
                          <el-input v-model="searchObj.germcode" style="width:150px" placeholder="双击开窗选择细菌" @dblclick.native="dialogGeram=true" :readonly="true" @clear.native="clearGeramer" :clearable="true"></el-input>
                      </td>
                      <td>动作</td>
                      <td>
                          <el-select v-model="searchObj.actions" clearable>
                              <el-option v-for="(item,index) in actionsOption" :key="index" :label="item.label" :value="item.value"></el-option>
                          </el-select>
                      </td>
                      <td>
                          <el-checkbox v-model="searchObj.validflag" true-label="1" false-label="0">有效</el-checkbox>
                      </td>
                  </tr>
              </table>
          </div>
          <div style="width:100%;float:left">
              <div style="float:right;right:5px;position:absolute">
                  <el-button @click="btnQuery" icon="el-icon-search" type="primary" v-has="'PINQUERY'" :disabled="changeflag">查询</el-button>
                  <el-button @click="btnAdd" icon="el-icon-plus" v-has="'PADD'" :disabled="changeflag">新增</el-button>
                  <el-button @click="btnModify" icon="el-icon-edit" v-has="'PMOD'" :disabled="changeflag">修改</el-button>
                  <el-button @click="btnDelete" icon="el-icon-delete" v-has="'PDELETE'" :disabled="changeflag">删除</el-button>
                  <el-button @click="btnSave" icon="el-icon-document" v-has="'PMODIFY'" :disabled="!changeflag">保存</el-button>
                  <el-button @click="btnClear" icon="el-icon-close" :disabled="!changeflag">取消</el-button>
                  <el-button icon="el-icon-upload2" @click="ExportCsv">导出</el-button>
                  <el-button icon="el-icon-files" @click="ImportCsv">导入</el-button>
                  <div class="upload-button">
                      <el-upload ref="upload" 
                          :action="url" accept=".dat" 
                          :before-upload="beforeUploadFile" :on-change="fileChange" :show-file-list="showFile"
                          :data="updata" :http-request="uploadOpt">
                          <el-button size="small" plain>选择文件</el-button>
                          <!-- <div slot="tip" class="el-upload__tip">只能上传DAT(*dat)文件，且不超过10M</div> -->
                      </el-upload>
                  </div>
              </div>
          </div>
      </div>
      <div class="pagecenter">
          <rm-layout-right splitcolor="white" movingcolor="#0000ff" :splitwidth=5 :fixsize=500>
              <template v-slot:fix>
                  <div style="height:100%">
                      <div class="rolecond-content">
                          <vxe-table :data="bactRulecondData" :loading="rolecondloading" :select-config="selectConfig" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}" @current-change="bactRulecondChange" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="rxTable1" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe @cell-dblclick="opendialog">
                              <!-- <vxe-table-column field="condtype" title="条件类型" width="105"></vxe-table-column> -->
                              <vxe-table-column field="condtypename" title="条件类型" width="80"></vxe-table-column>
                              <vxe-table-column field="validflag" title="满足" width="50" align="center">
                                  <template v-slot="{row}">
                                      <span v-if="!!row.operrator">
                                          <i v-if="row.operrator=='='" class="el-icon-success" style="font-size:18px;color:green"></i>
                                          <i v-else class="el-icon-error" style="font-size:18px;color:red"></i>
                                      </span>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="condvaluename" title="取值(双击开窗)" width="345"></vxe-table-column>
                          </vxe-table>
                      </div>
                      <div class="otheritem-content">
                          <div style="border:1px solid #CCC;font-size:12px;height:50px">
                              <table style="width:100%;border-spacing:0px;">
                                  <tr>
                                      <td style="width:78px;padding-left:1px">
                                          <font>其他项目<br>(双击开窗)</font>
                                      </td>
                                      <td>
                                          <el-input v-model="bact_rule.condition2" type="textarea" @dblclick.native="opendialog({column:{property:'condition2'}})" readonly></el-input>
                                      </td>
                                  </tr>
                              </table>
                          </div>
                      </div>
                      <div style="width:100%;float:left;height:50px;margin-top:5px;">
                          <div style="border:1px solid #CCC;font-size:12px;height:50px">
                              <table style="width:100%;border-spacing:0px;">
                                  <tr>
                                      <td style="width:78px;padding-left:1px">
                                          <font>抗生素规则<br>(双击开窗)</font>
                                      </td>
                                      <td>
                                          <el-input v-model="bact_rule.condition1" type="textarea" @dblclick.native="opendialog({column:{property:'condition1'}})" readonly></el-input>
                                      </td>
                                  </tr>
                              </table>
                          </div>
                      </div>
                      <div style="width:100%;float:left;height:160px;margin-top:5px;">
                          <vxe-table :data="bactRuleActionData" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false,activeMethod:rxTable2Active}" border fit @cell-dblclick="opendialog" height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="rxTable2" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                              <vxe-table-column field="validflag" title="有效" width="50" align="center">
                                  <template v-slot="{row}">
                                      <el-checkbox v-model="row.validflag" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="actions" title="操作规则" width="125" :edit-render="{name:'select', options: actionsOption}"></vxe-table-column>
                              <vxe-table-column field="actionContent" title="操作内容(双击开窗)" width="325"></vxe-table-column>
                              <template v-slot:fix>
                                  <div style="font-size:12px;padding-top:3px;background-color:#fff;text-align:center">
                                      <el-button style="background-color:#e6e6e6;color:black" @click="btnAddDetail">新增明细</el-button>
                                      <el-button style="background-color:#e6e6e6;color:black" @click="btnDeleteDetail">删除明细</el-button>
                                  </div>
                              </template>
                          </vxe-table>
                      </div>
                  </div>
              </template>
              <div style="height:100%;width:100%;">
                  <vxe-table :data="bactRuleData" :loading="loading" :keyboard-local-config="keyLocalConfig" :keyboard-config="keyConfig" 
                      :row-class-name="rowClassName" :select-config="selectConfig" :sort-config="{trigger: 'cell'}" 
                      :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false,activeMethod:activeMethod}" 
                      @current-change="currentChange" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row 
                      @cell-dblclick="opendialog" highlight-hover-column ref="xTable" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                      <vxe-table-column field="seq" title="序号" width="45" align="center"></vxe-table-column>
                      <vxe-table-column field="rulecode" title="规则代码" width="70"></vxe-table-column>
                      <vxe-table-column field="ruletype" title="规则类型" width="80" :edit-render="{name:'select', options: ruletypeOption}"></vxe-table-column>
                      <vxe-table-column field="rulename" title="规则名称" width="100"></vxe-table-column>
                      <vxe-table-column field="validflag" title="有效" width="45" align="center">
                          <template v-slot="{row}">
                              <el-checkbox v-model="row.validflag" true-label="1" false-label="0" disabled="disabled"></el-checkbox>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column field="rescomments" title="说明(双击开窗查看)" width="400"></vxe-table-column>
                      <vxe-table-column field="condition1" title="抗生素条件" width="5">
                          <template v-slot:header="{ column }">
                              <!--有用，勿删-->
                          </template>
                          <template v-slot="{row}">
                          </template>
                      </vxe-table-column>
                  </vxe-table>
              </div>
          </rm-layout-right>
      </div>
      <!--左表说明弹窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="说明" :visible.sync="dialogComment" width="560px">
          <el-input v-model="dialogbactrule.rescomments" type="textarea" :rows="12" readonly></el-input>
          <!-- <span slot="footer" class="dialog-footer">
              <el-button type="primary" @click="dialogCommentSave">确 定</el-button>
              <el-button @click="dialogComment = false">取 消</el-button>
          </span> -->
      </el-dialog>

      <!--右上表多选弹窗--->
      <el-dialog width="auto" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogCondvalue" v-if="dialogCondvalue" :destroy-on-close="true">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" :param="condTitle" :age="ageList" @changeAge="changeAge" @change="closedialog" :prono="'LIS848'" :LIS848radio="LIS848radio"></rm-SqlMultiple>
      </el-dialog>

      <!--细菌弹窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="细菌" :visible.sync="dialogGeram" width="700px">
          <div style="width:100%;height:35px;border:1px solid #CCC">
              <table style="width:100%" class="table1style">
                  <tr>
                      <td>查询</td>
                      <td>
                          <el-input v-model="txtmedsearch" placeholder="代码|名称|输入码" clearable></el-input>
                      </td>
                      <td>
                          <el-radio-group v-model="geramradio" @change="geramradioChange">
                              <el-radio :label="1">细菌一级分类</el-radio>
                              <el-radio :label="2">菌科</el-radio>
                              <el-radio :label="3">菌属</el-radio>
                              <el-radio :label="4">细菌</el-radio>
                          </el-radio-group>
                      </td>
                  </tr>
              </table>
          </div>
          <div style="width:100%;height:300px;margin-top:5px">
              <vxe-table :data="list" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable1" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe @cell-dblclick="selectGeramer" @current-change="GeramerChange">
                  <vxe-table-column type="index" title="NO." width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="data" title="代码" width="105"></vxe-table-column>
                  <vxe-table-column field="display" title="名称" width="205"></vxe-table-column>
                  <vxe-table-column field="inputcode" title="输入码" width="195"></vxe-table-column>
              </vxe-table>
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button type="primary" @click="confirmGeramer">确 定</el-button>
              <el-button @click="dialogGeram = false">取 消</el-button>
          </span>
      </el-dialog>

      <!--右下表操作内容弹窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="操作内容" :visible.sync="dialogAction" :width="['AC','UC','CT','AA','IF','HM'].indexOf(pop_ruleaction.actions)>-1?'560px':'560px'">
          <div v-if="['UC','CT','AA','IF','HM'].indexOf(pop_ruleaction.actions)>-1">
              <el-input v-model="pop_ruleaction.txtresult" type="textarea" :rows="10"></el-input>
          </div>
          <div v-else-if="['MM','AM','DM'].indexOf(pop_ruleaction.actions)>-1">
              <table style="width:100%" class="table1style">
                  <tr>
                      <td width="60px">抗&nbsp;&nbsp;生&nbsp;&nbsp;素</td>
                      <td>
                          <!-- <el-select v-model="pop_ruleaction.medcode" placeholder="">
                              <el-option v-for="(item,index) in labmedOption" :key="index" :label="item.medname" :value="item.medcode"></el-option>
                          </el-select> -->
                          <rm-ddl-common ref="ddllabmed" datatype="labmed" dataname="抗生素" v-model="pop_ruleaction.medcode" width="100%" :readonly="true" :clearable="true" key="1"></rm-ddl-common>
                      </td>
                  </tr>
                  <tr v-if="['MM','AM'].indexOf(pop_ruleaction.actions)>-1">
                      <td>结果标志</td>
                      <td >
                          <el-input v-if="isFormula=='1'" style="width:75%" v-model="pop_ruleaction.flagformula" placeholder="双击弹窗修改" clearable :disabled="formdisabled1"  @dblclick.native="changeFlagVal('flagformula')"></el-input>
                          <el-select v-if="isFormula!='1'" v-model="pop_ruleaction.result_flag" clearable :disabled="formdisabled1" :style="['MM'].indexOf(pop_ruleaction.actions)>-1?'width:75%':'width:100%'">
                              <el-option v-for="(item,index) in resultflagOption" :key="index" :label="item.name" :value="item.value"></el-option>
                          </el-select>
                          <el-checkbox  v-if="['MM'].indexOf(pop_ruleaction.actions)>-1" true-label="1" false-label="0" v-model="isFormula" style="margin-left: 5px;" >使用计算公式</el-checkbox>
                      </td>
                  </tr>
                  <!-- 增加抗生素时，kb、mic值与结果标志只能填一个 -->
                  <tr v-if="['AM'].indexOf(pop_ruleaction.actions)>-1">
                      <td>Rad值：</td>
                      <td><el-input v-model="pop_ruleaction.radformula" placeholder="双击弹窗修改" clearable :disabled="formdisabled2" readonly @dblclick.native="changeRadMicVal('radformula')"></el-input></td>
                  </tr>
                  <tr v-if="['AM'].indexOf(pop_ruleaction.actions)>-1">
                      <td>Mic值：</td>
                      <td><el-input v-model="pop_ruleaction.micformula" placeholder="双击弹窗修改" clearable :disabled="formdisabled3" readonly @dblclick.native="changeRadMicVal('micformula')"></el-input></td>
                  </tr>
                  <tr v-if="pop_ruleaction.radformula">
                      <td>实验方法</td>
                      <td>
                          <el-select v-model="pop_ruleaction.medmethod" @change="changeMedmethod" style="width:100%">
                              <el-option label="KB" value="KB"></el-option>
                              <el-option label="ETest" value="ETest"></el-option>
                          </el-select>
                      </td>
                  </tr>
              </table>
          </div>
          <div v-else-if="['BM','UPM','RDM'].indexOf(pop_ruleaction.actions)>-1">
              <table style="width:100%" class="table1style">
                  <tr>
                      <td>抗&nbsp;生&nbsp;素</td>
                      <td>
                          <!-- <el-select v-model="pop_ruleaction.medcode" placeholder="">
                              <el-option v-for="(item,index) in labmedOption" :key="index" :label="item.medname" :value="item.medcode"></el-option>
                          </el-select> -->
                          <rm-ddl-common ref="ddllabmed" datatype="labmed" dataname="抗生素" v-model="pop_ruleaction.medcode" width="100%" :readonly="true" :clearable="true" key="2"></rm-ddl-common>
                      </td>
                  </tr>
              </table>
          </div>
          <div v-else-if="['AC'].indexOf(pop_ruleaction.actions)>-1">
               <table style="width:100%" class="table1style">
                  <tr>
                      <td>专&nbsp;家&nbsp;评&nbsp;语</td>
                      <td> 
                          <rm-ddl-common  :append-to-body="true" ref="ddlgermcomment" datatype="germcomment" dataname="专家评语" v-model="pop_ruleaction.txtresult" width="100%" :readonly="true" :clearable="true" @change="germcommentchange"  key="3"></rm-ddl-common>
                      </td>
                  </tr>
              </table>
          </div>
          <div v-else>
              <table style="width:100%" class="table1style">
                  <tr>
                      <td>耐&nbsp;药&nbsp;机&nbsp;制</td>
                      <td>
                          <!-- <el-select v-model="pop_ruleaction.rescode" @change="rescodeChange">
                              <el-option v-for="(item,index) in resdictOption" :key="index" :label="item.label" :value="item.value"></el-option>
                          </el-select> -->
                          <rm-ddl-common ref="ddlrescode" datatype="resdict" dataname="耐药机制" v-model="pop_ruleaction.rescode" width="100%" @change="rescodeChange" key="3"></rm-ddl-common>
                      </td>
                  </tr>
                  <tr>
                      <td>危急值标志</td>
                      <td>
                          <el-checkbox true-label="1" false-label="0" v-model="pop_ruleaction.alertflag" :disabled="true"></el-checkbox>
                      </td>
                  </tr>
              </table>
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button type="primary" @click="dialogActionSave">确 定</el-button>
              <el-button @click="dialogAction = false">取 消</el-button>
          </span>
      </el-dialog>

      <!--抗生素规则-->
      <el-dialog title="抗生素规则" v-el-drag-dialog :close-on-click-modal="false" :visible.sync="dialoglabmedrule" width="840px" :destroy-on-close="true">
          <div style="height:460px;width:100%;position:relative;">
              <div class="pagetop-p">
                  <el-input v-model="pbactrule.condition1" type="textarea" :rows="3" ref="rulecondition" style="width:100%"></el-input>
              </div>
              <div class="pagecenter-p">
                  <div class="middle-center-p">
                      <rm-layout-top splitcolor="white" :splitwidth=0 :fixsize=35>
                          <template v-slot:fix>
                              <div style="height:35px;border:1px solid #CCC;border-bottom:none">
                                  <table class="table1style">
                                      <tr>
                                          <td>快速查询</td>
                                          <td>
                                              <el-input style="width:260px" placeholder="代码|名称|输入码|英文" v-model="ruletxtmedsearch"></el-input>
                                          </td>
                                      </tr>
                                  </table>
                              </div>
                          </template>
                          <div style="height:100%;width:100%;background-color:#ddccbb;">
                              <vxe-table show-overflow ref="xTable2" height="auto" :select-config="{reserve: true}" :data.sync="labmedlist" show-header-overflow highlight-current-row highlight-hover-row resizable border @cell-click="rulemedChangeEvent" size="mini">
                                  <vxe-table-column field="medcode" title="药物代码" width="75" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medname" title="药物名称" width="135" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medname_en" title="药物英文" width="80" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="inputcode" title="录入码" width="95" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medconc" title="药物浓度" width="75" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="whocode" title="WHONET代码" width="100" header-align="center"></vxe-table-column>
                              </vxe-table>
                          </div>
                      </rm-layout-top>
                  </div>
                  <div class="middle-right-p">
                      <el-radio-group v-model="ruleradio">
                          <table style="width:100%" class="table2style">
                              <tr>
                                  <td align="left">
                                      <el-radio :label="0">结果标志(R,I,S)</el-radio>
                                  </td>
                                  <td align="left">
                                      <el-radio :label="1">药敏结果</el-radio>
                                  </td>
                              </tr>
                              <tr>
                                  <td align="left">
                                      <el-radio :label="2">抑菌圈直径(Rad)</el-radio>
                                  </td>
                                  <td align="left">
                                      <el-radio :label="3">抑菌浓度(Mic)</el-radio>
                                  </td>
                              </tr>
                              <tr>
                                  <td align="left">
                                      <el-radio :label="4">试验方法=Disk</el-radio>
                                  </td>
                                  <td align="left">
                                      <el-radio :label="5">试验方法=Mic</el-radio>
                                  </td>
                              </tr>
                              <tr>
                                  <td align="left">
                                      <el-button @click.native="anyonemed('任意抗生素')">任意抗生素</el-button>
                                  </td>
                              </tr>
                          </table>
                      </el-radio-group>
                      <table style="width:100%">
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('>','0')">&gt;</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('<','0')">&lt;</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('<=','0')">&lt;=</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('>=','0')">&gt;=</el-button>
                              </td>
                          </tr>
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('=','0')">=</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('<>','0')">&lt;&gt;</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('AND','0')">AND</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('OR','0')">OR</el-button>
                              </td>
                          </tr>
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('NOT','0')">NOT</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('R','1')">'R'</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('I','1')">'I'</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('S','1')">'S'</el-button>
                              </td>
                          </tr>
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('+','0')">+</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('-','0')">-</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('*','0')">*</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('/','0')">/</el-button>
                              </td>
                          </tr>
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('IN','0')">IN</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('(','0')">(</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate(')','0')">)</el-button>
                              </td>
                              <td>
                              </td>
                          </tr>
                          <tr>
                              <td colspan="4">
                                  <span style="font-size:12px">说明：[]内用：分成三段，第一段是抗生素代码，第二段是取值类型，第三段是抗生素不存在时用哪个值代替</span>
                              </td>
                          </tr>
                      </table>
                      <table style="width:100%;margin-top:15px" border="0">
                          <tr>
                              <td style="text-align:center">
                                  <el-button @click="verifylanmedrule" icon="el-icon-document">确 定</el-button>
                                  <el-button @click="dialoglabmedrule = false" icon="el-icon-close">取 消</el-button>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
          </div>
      </el-dialog>
     <el-dialog title="抗生素公式" v-el-drag-dialog :close-on-click-modal="false" :visible.sync="dialoglabmedformula" width="840px" :destroy-on-close="true">
          <div style="height:460px;width:100%;position:relative;">
              <div class="pagetop-p">
                  <el-input v-model="medformula" type="textarea" :rows="3" ref="formulacondition" style="width:100%"></el-input>
              </div>
              <div class="pagecenter-p">
                  <div class="middle-center-p">
                      <rm-layout-top splitcolor="white" :splitwidth=0 :fixsize=35>
                          <template v-slot:fix>
                              <div style="height:35px;border:1px solid #CCC;border-bottom:none">
                                  <table class="table1style">
                                      <tr>
                                          <td>快速查询</td>
                                          <td>
                                              <el-input style="width:260px" placeholder="代码|名称|输入码|英文" v-model="formulatxtmedsearch"></el-input>
                                          </td>
                                      </tr>
                                  </table>
                              </div>
                          </template>
                          <div style="height:100%;width:100%;background-color:#ddccbb;">
                              <vxe-table show-overflow ref="xTable2" height="auto" :select-config="{reserve: true}" :data.sync="labmedlist" show-header-overflow highlight-current-row highlight-hover-row resizable border @cell-click="formulamedChangeEvent" size="mini">
                                  <vxe-table-column field="medcode" title="药物代码" width="75" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medname" title="药物名称" width="135" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medname_en" title="药物英文" width="80" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="inputcode" title="录入码" width="95" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medconc" title="药物浓度" width="75" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="whocode" title="WHONET代码" width="100" header-align="center"></vxe-table-column>
                              </vxe-table>
                          </div>
                      </rm-layout-top>
                  </div>
                  <div class="middle-right-p">
                       <el-radio-group v-model="formularadio">
                          <table style="width:100%" class="table2style">
                              <tr>
                                  <td align="left">
                                      <el-radio :label="2">抑菌圈直径(Rad)</el-radio>
                                  </td>
                                  <td align="left">
                                      <el-radio :label="3">抑菌浓度(Mic)</el-radio>
                                  </td>
                              </tr>
                          </table>
                      </el-radio-group>
                      <table style="width:100%" class="table2style">
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('+','0','formula')">+</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('-','0','formula')">-</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('*','0','formula')">*</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('/','0','formula')">/</el-button>
                              </td>
                          </tr>
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate('(','0','formula')">(</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="operate(')','0','formula')">)</el-button>
                              </td>
                              <td>
                              </td>
                          </tr>
                          <tr>
                              <td colspan="4">
                                  <!-- <span style="font-size:12px"></span>   说明：[抗生素代码]，表示mic值，[@抗生素代码]表示Rad值 -->
                              </td>
                          </tr>
                      </table>
                      <table style="width:100%;margin-top:15px" border="0">
                          <tr>
                              <td style="text-align:center">
                                  <el-button @click="verifylanmedformula" icon="el-icon-document">确 定</el-button>
                                  <el-button @click="dialoglabmedformula = false" icon="el-icon-close">取 消</el-button>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
          </div>
      </el-dialog>
      <el-dialog title="结果标志公式" v-el-drag-dialog :close-on-click-modal="false" :visible.sync="dialoglabflagformula" width="840px" v-if="dialoglabflagformula" >
          <div style="height:460px;width:100%;position:relative;">
              <div class="pagetop-p">
                  <el-input v-model="flagformula" type="textarea" :rows="3" ref="flagformulacondition" style="width:100%"></el-input>
              </div>
              <div class="pagecenter-p">
                  <div class="middle-center-p">
                      <rm-layout-top splitcolor="white" :splitwidth=0 :fixsize=35>
                          <template v-slot:fix>
                              <div style="height:35px;border:1px solid #CCC;border-bottom:none">
                                  <table class="table1style">
                                      <tr>
                                          <td>快速查询</td>
                                          <td>
                                              <el-input style="width:260px" placeholder="代码|名称|输入码|英文" v-model="flagformulatxtmedsearch"></el-input>
                                          </td>
                                      </tr>
                                  </table>
                              </div>
                          </template>
                          <div style="height:100%;width:100%;background-color:#ddccbb;">
                              <vxe-table show-overflow ref="xTable2" height="auto" :select-config="{reserve: true}" :data.sync="labmedlist" show-header-overflow highlight-current-row highlight-hover-row resizable border @cell-click="flagformulamedChangeEvent" size="mini">
                                  <vxe-table-column field="medcode" title="药物代码" width="75" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medname" title="药物名称" width="135" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medname_en" title="药物英文" width="80" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="inputcode" title="录入码" width="95" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="medconc" title="药物浓度" width="75" sortable header-align="center"></vxe-table-column>
                                  <vxe-table-column field="whocode" title="WHONET代码" width="100" header-align="center"></vxe-table-column>
                              </vxe-table>
                          </div>
                      </rm-layout-top>
                  </div>
                  <div class="middle-right-p">
                       <el-radio-group v-model="flagformularadio">
                          <table style="width:100%" class="table2style">
                              <tr>
                                  <!-- <td align="left">
                                      <el-radio :label="2">抑菌圈直径(Rad)</el-radio>
                                  </td>
                                  <td align="left">
                                      <el-radio :label="3">抑菌浓度(Mic)</el-radio>
                                  </td> -->
                                  <td align="left">
                                      <el-radio :label="0">结果标志(R,I,S)</el-radio>
                                  </td>
                              </tr>
                              <tr>
                                  <td align="left">
                                      <el-button @click.native="anyonemedflag('任意抗生素')">任意抗生素</el-button>
                                  </td>
                                  <td align="left">
                                      <el-button @click.native="anyonemedflag('SELF')">SELF</el-button>
                                  </td>
                              </tr>
                          </table>
                      </el-radio-group>
                      <table style="width:100%">
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('if','0')">if</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('R','1')">'R'</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('I','1')">'I'</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('S','1')">'S'</el-button>
                              </td>
                          </tr>
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('==','0')">==</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('R*','1')">'R*'</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('I*','1')">'I*'</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('S*','1')">'S*'</el-button>
                              </td>
                              
                          </tr>
                          <tr>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('POS','1')">'POS'</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('NEG','1')">'NEG'</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate('(','0')">(</el-button>
                              </td>
                              <td>
                                  <el-button style="width: 50px;margin:4px;" @click="flagoperate(')','0')">)</el-button>
                              </td>
                              <td>
                              </td>
                          </tr>
                          <tr>
                              <td colspan="4">
                                  <span style="font-size:12px">说明：if()内用为判断条件，满足条件则赋值第一个逗号后的值，否则为第二个逗号后（判断条件）的值</span>
                              </td>
                          </tr>
                      </table>
                      <table style="width:100%;margin-top:15px" border="0">
                          <tr>
                              <td style="text-align:center">
                                  <el-button @click="verifylanflagformula" icon="el-icon-document">确 定</el-button>
                                  <el-button @click="dialoglabflagformula = false" icon="el-icon-close">取 消</el-button>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
          </div>
      </el-dialog>
      <!--新增，修改弹窗-->
      <el-dialog :title="headtitle" :visible.sync="dialogEditrule" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false">
          <el-form ref="rowbactrule" :model="RowBactRule" class="table1style">
              <table style="text-align:right;font-size:12px;width:100%">
                  <tr>
                      <td>规则代码</td>
                      <td>
                          <el-input v-model="RowBactRule.rulecode" :disabled="disabled" ref="popinput1" @keyup.enter.native="inputautofocus('popinput1')"></el-input>
                      </td>
                      <td>规则类别</td>
                      <td>
                          <el-select v-model="RowBactRule.ruletype" clearable style="width:100%" ref="popinput2" @keyup.enter.native="inputautofocus('popinput2')" filterable>
                              <el-option v-for="item in ruletypeOption" :key="item.value" :value="item.value" :label="item.label"></el-option>
                          </el-select>
                      </td>

                  </tr>
                  <tr>
                      <td>规则名称</td>
                      <td>
                          <el-input v-model="RowBactRule.rulename" ref="popinput3" @keyup.enter.native="inputautofocus('popinput3')"></el-input>
                      </td>
                      <td>规则序号</td>
                      <td align="left">
                          <el-input v-model.number="RowBactRule.seq" type="number" ref="popinput4" @keyup.enter.native="inputautofocus('popinput4')" style="width:100px"></el-input>
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                          <el-checkbox v-model="RowBactRule.validflag" @keyup.enter.native="inputautofocus('popinput5')" ref="popinput5" true-label="1" false-label="0">有效
                          </el-checkbox>
                      </td>
                  </tr>
                  <tr>
                      <td>规则说明</td>
                      <td colspan="5">
                          <el-input type="textarea" rows="5" v-model="RowBactRule.rescomments" ref="popinput6" @keyup.enter.native="inputautofocus('popinput6')" width="100%"></el-input>
                      </td>
                  </tr>
              </table>
          </el-form>
          <span slot="footer" class="dialog-footer">
              <el-button @click.native="dialogEditruleSave()">确 定</el-button>
              <el-button @click="dialogEditrule = false" :autofocus="true">取 消</el-button>
          </span>
      </el-dialog>
      
      <!-- 其他条件 -->
      <el-dialog title="其他条件向导" v-el-drag-dialog :close-on-click-modal="false" :visible.sync="outerVisible" height="500px" width="1010px">
          <el-dialog :append-to-body="true" :close-on-click-modal="false" :title="dialogtitle" :before-close="cancelinnerdialog" :visible.sync="dialogTableVisible" v-if="dialogx">
              <rm-pop-common @change="popcomchange" @cancel="cancelinnerdialog" :datatype="dataclass"></rm-pop-common>
          </el-dialog>
          <el-form>
              <el-row>
                  <div style="width:100%;float:left">
                      <el-input type="textarea" v-model="dialogtopdata" readonly="readonly" disabled="disabled" id="topdiv"></el-input>
                  </div>
                  <div style="width:100%;float:left;margin-top:5px">
                      <el-input type="textarea" v-model="dialogmiddledata" ref="middledataautofocus" id="middiv" @input="targetinput"></el-input>
                  </div>
              </el-row>
              <el-row>
                  <div style="height:400px;border:1px solid #CCC;margin-top:5px">
                      <div style="width:100%;float:left;height:100%;">
                          <div style="position:absolute;right:255px;left:0px;overflow:auto">
                              <div style="width:100%;float:left;height:40px;">
                                  <div style="width:60%;float:left">
                                      <el-form>
                                          <el-form-item label="项目快速查找" label-width="120">
                                              <el-input v-model="quicklysearch" style="width:250px" placeholder="报告项目代码或报告项目名称或缩写" @keyup.enter.native="PopListSearch"></el-input>
                                          </el-form-item>
                                      </el-form>
                                  </div>
                                  <div style="width:40%;float:left;margin-top:5px">
                                      <el-button @click="verifyCondition2" icon="el-icon-document">确 定</el-button>
                                      <el-button @click="outerVisible = false" :autofocus="true" icon="el-icon-close">取 消</el-button>
                                  </div>
                              </div>
                              <div style="width:100%;float:left;height:360px;">
                                  <vxe-table ref="otheritemTable" :data.sync="otheritemOption" height="auto" size="mini" row-id="id" resizable border 
                                      header-align="center" show-overflow show-header-overflow highlight-current-row highlight-hover-row 
                                      :select-config="{reserve: true}" @cell-click="popcurrentChangeEvent">
                                      <vxe-table-column type="index" title="NO." width="50"></vxe-table-column>
                                      <vxe-table-column field="itemcode_en" title="英文缩写" width="100" sortable></vxe-table-column>
                                      <vxe-table-column field="rpt_itemname" title="报告项目名称" width="130" sortable header-align="center"></vxe-table-column>
                                      <!-- <vxe-table-column field="itemtips" title="项目备注" width="140" sortable header-align="center"></vxe-table-column>
                                      <vxe-table-column field="itemclassname" title="项目归类" width="90" sortable header-align="center"></vxe-table-column>
                                      <vxe-table-column field="instrclassname" title="仪器类别" width="80" header-align="center"></vxe-table-column> -->
                                      <vxe-table-column field="rpt_itemcode" title="报告项目代码" width="100" header-align="center"></vxe-table-column>
                                  </vxe-table>
                              </div>
                          </div>
                      </div>
                      <div style="width:255px;float:left;height:100%;position:absolute;right:0px;">
                          <div style="text-align:center;position:realative">
                              <table style="text-align:center">
                                  <tr>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('+','1')">+</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('-','1')">-</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('*','1')">*</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('/','1')">/</el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('>','1')">&gt;</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('>=','1')">&gt;=</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('<','1')">&lt;</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('<=','1')">
                                              &lt;=</el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('(','1')">(</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate(')','1')">)</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('&&','1')">AND</el-button>
                                      </td>
                                      <td>
                                          <el-button style="width:52.5px;margin:4px" @click="otherItemOperate('||','1')">
                                              OR</el-button>
                                      </td>
                                  </tr>
                              </table>
                              <table>
                                  <tr>
                                      <td colspan="2">
                                          <el-button style="width:100px;margin:4px" @click="otherItemOperate('年龄','-1')">年龄</el-button>
                                      </td>
                                      <td colspan="2">
                                          <el-button style="width:135px;" @click="otherItemOperate('任意项目 数值结果','-1')">任意项目 数值结果</el-button>
                                      </td>

                                  </tr>
                                  <tr>
                                      <td colspan="2">
                                          <el-button style="width: 100px;margin:4px" @click="otherItemOperate('性别','2')">性别</el-button>
                                      </td>
                                      <td colspan="2">
                                          <el-button style="width:135px;" @click="otherItemOperate('任意项目 文字结果','-1')">任意项目 文字结果</el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td colspan="2">
                                          <el-button style="width: 100px;margin:4px;" @click="otherItemOperate('病人类型','2')">病人类型</el-button>
                                      </td>
                                      <td colspan="2">
                                          <el-button style="width:135px;text-align:center" @click="otherItemOperate('任意项目 危急值标志','-1')">任意项目 危急值标志</el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td colspan="2">
                                          <el-button style="width: 100px;margin:4px;" @click="otherItemOperate('科室','2')" @contextmenu.prevent.native="rightEvent('科室')">科室</el-button>
                                      </td>
                                      <td colspan="2">
                                          <el-button style="width:135px;" @click="otherItemOperate('任意项目 复查标志','-1')">任意项目 复查标志</el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td colspan="2">
                                          <el-button style="width: 100px;margin:4px;" @click="otherItemOperate('标本类型','2')" @contextmenu.prevent.native="rightEvent('标本类型')">标本类型</el-button>
                                      </td>
                                      <td colspan="2">
                                          <el-button style="width:135px;" @click="otherItemOperate('任意项目 结果标志','-1')">任意项目 结果标志</el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td colspan="2">
                                          <el-button style="width: 100px;margin:4px" @click="otherItemOperate('标本状态备注','2')">标本状态备注</el-button>
                                      </td>
                                      <td colspan="2">
                                          <el-button style="width:135px;" @click="otherItemOperate('任意项目 仪器报警','-1')">任意项目 仪器报警</el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td colspan="2">
                                          <el-button style="width: 100px;margin:4px" @click="otherItemOperate('报告单备注','2')">报告单备注</el-button>
                                      </td>
                                      <td colspan="2">
                                          <el-button style="width:135px;" @click="otherItemOperate('任意项目代码','-1')">任意项目代码</el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td colspan="2">
                                          <el-button style="width: 100px;margin:4px" @click="otherItemOperate('诊断','2')" @contextmenu.prevent.native="rightEvent('诊断')">诊断</el-button>
                                      </td>
                                      <td colspan="2">
                                          <el-button style="width:135px;" @click="otherItemOperate('诊断ICD10','2')" @contextmenu.prevent.native="rightEvent('诊断ICD10')">诊断ICD10</el-button>
                                      </td>
                                  </tr>
                              </table>
                          </div>
                      </div>
                  </div>
              </el-row>
          </el-form>

      </el-dialog>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  name: "LIS848",
  data() {
      return {
          dialogEditrule: false,
          headtitle: "",
          ruleradio: 0,
          flagformularadio:0,
          disabled: false,
          RowBactRule: {},
          geramradio: 1,
          ruletxtmedsearch: "", //抗生素规则查询
          formulatxtmedsearch: "",
          formularadio: 3,
          dialoglabmedformula: false,
          medformula: "",
          dialoglabflagformula: false,
          flagformula:"",//结果标志计算公式
          LIS848radio: 1,
          pop_ruleaction: {},
          bact_ruleaction: {},
          changeflag: false,
          searchObj: {
              ruletype: "",
              validflag: "0",
              specimen: "",
              germkind: "",
              germcode: "",
              actions: "",
          }, //查询对象
          rolecondloading: false,
          geramdata: [], //查询细菌数据集
          fbact_rule: {},
          bact_rule: {
              // rulecode: "",
              // ruletype: "",
              // rulename: "",
              // rescomments: "",
              // condition1: "",
              // condition2: "",
              // condcomment: "",
              // validflag: "0",
              // seq: "",
          },
          bactrulecode: "",
          txtmedsearch: "", //查询中细菌开窗
          bactRulecondRow: [],
          ruleconds: {}, //右上取值行选中记录值
          dialogbactrule: {}, //主表双击开窗
          dialogCondvalue: false, //右上取值双击开窗
          condTitle: "",
          ageList: [],
          // bactcount: "",
          dialogCondition1: false, //抗生素条件开窗
          dialogAction: false, //右下开窗
          dialogComment: false, //主表说明开窗
          dialogGeram: false, //查询细菌开窗
          dialoglabmedrule: false, //抗生素规则
          pbactrule: [], //抗生素规则弹窗前记录抗生素规则
          loading: false,
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
              isArrow: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          pageinitloading: false,
          okFirstLoading: false,
          selectConfig: { tigger: "row" },
          actionindex: "M",
          multichktitle: "",
          fieldname: "",
          AddData: [],
          ModData: [],
          option1: [],
          option2: [],
          bactRuleData: [],
          bactRulecondData: [],
          bactRuleActionData: [],
          //bactcond预备数据
          condtypeInfo: [
              { code: "pat_typecode", name: "病人类型", seq: "1", sortseq: 0 },
              { code: "pat_sex", name: "性别", seq: "2", sortseq: 0 },
              { code: "pat_ageyear", name: "年龄", seq: "3", sortseq: 0 },
              { code: "req_deptno", name: "科室", seq: "4", sortseq: 0 },
              { code: "req_wardno", name: "病区", seq: "5", sortseq: 0 },
              { code: "specimen", name: "标本类型", seq: "6", sortseq: 0 },
              { code: "pat_diag", name: "诊断", seq: "7", sortseq: 0 },
              { code: "rescode", name: "耐药类型", seq: "8", sortseq: 0 },
              { code: "bloodculture", name: "血培养结果", seq: "9", sortseq: 0 },
              { code: "germgram", name: "细菌一级分类", seq: "10", sortseq: 0 },
              { code: "germkind", name: "菌科", seq: "11", sortseq: 0 },
              { code: "germgroup", name: "菌属", seq: "12", sortseq: 0 },
              { code: "rpt_itemcode", name: "细菌", seq: "13", sortseq: 0 },
              { code: "bactcount", name: "菌落计数", seq: "14", sortseq: 0 },
              { code: "purpose", name: "检验目的", seq: "15", sortseq: 0 },
              // { code: "otheritem", name: "其他项目", seq: "15", sortseq: 0 },
          ],
          labmedOption: [],
          pat_typecodeOption: [],
          pat_sexOption: [],
          req_wardnoOption: [],
          req_deptnoOption: [],
          patdialogOption: [],
          rptunitidOption: [],
          bloodcultureOption: [],
          rescodeOption: [],
          rpt_itemcodeOption: [],
          otheritemOption: [],
          germkindOption: [],
          germgroupOption: [],
          ruletypeOption: [],
          actionsOption: [],
          resdictOption: [],
          specimenOption: [],
          germgramOption: [
              {
                  display: "+",
                  data: "+",
                  inputcode: "+",
              },
              {
                  display: "-",
                  data: "-",
                  inputcode: "-",
              },
              {
                  display: "a",
                  data: "a",
                  inputcode: "a",
              },
              {
                  display: "b",
                  data: "b",
                  inputcode: "b",
              },
              {
                  display: "f",
                  data: "f",
                  inputcode: "f",
              },
              {
                  display: "m",
                  data: "m",
                  inputcode: "m",
              },
              {
                  display: "o",
                  data: "o",
                  inputcode: "o",
              },
              {
                  display: "w",
                  data: "w",
                  inputcode: "w",
              },
          ],
          bloodcultureOption: [
              { display: "阳性(+)", data: "+", inputcode: "YX+" },
              { display: "阴性(-)", data: "-", inputcode: "YX-" },
          ],
          // resultflagOption: [
          //     { label: "R(耐药)", value: "R" },
          //     { label: "I(中介)", value: "I" },
          //     { label: "S(敏感)", value: "S" },
          //     { label: "N(无)", value: "N" },
          //     { label: "SDD(剂量依赖性敏感)", value: "SDD" },
          //     { label: "NS(非敏感)", value: "NS" },
          //     { label: "+", value: "+" },
          //     { label: "-", value: "-" },
          //     { label: "野生型", value: "WT" },
          //     { label: "非野生型", value: "NWT" },
          // ],
          resultflagOption:[],
          bactcountOption: [
              { display: "为空", data: "为空", inputcode: "WK" },
              { display: "不为空", data: "不为空", inputcode: "BWK" },
          ],
          // otheritemOption: [
          //     { display: "阴性结果", data: "阴性结果", inputcode: "YXJG" },
          //     { display: "涂片结果", data: "涂片结果", inputcode: "TPJG" },
          // ],
          outerVisible: false,
          dialogx: false,
          dialogtitle: "",
          dataclass: "",
          dialogtopdata: "",
          dialogmiddledata: "",
          quicklysearch: "",
          form: {},
          showFile: false,
          url: "",
          updata: { action: "BACCOMMOMUPLOAD" }, 
          formdisabled1: false,
          formdisabled2: false,
          formdisabled3: false,
          chageName: "",
          chageFlagName: "",
          isFormula:"0",
      };
  },
  created() {
      this.initOption();
      this.InitPage(); //初始化主列表
      this.initdata(); //初始化下拉框的数据
  },
  mounted(){
      this.getMedResultList();
  },
  watch: {
      pop_ruleaction: {
          handler: function (val, oldVal) { // 更新列表状态
              if (['AM'].indexOf(this.pop_ruleaction.actions) < 0) return;
              if (val.radformula) {
                  this.formdisabled1 = true;
                  this.formdisabled2 = false;
                  this.formdisabled3 = true;
              } else if (val.micformula) {
                  this.formdisabled1 = true;
                  this.formdisabled2 = true;
                  this.formdisabled3 = false;
              } else if (val.result_flag) {
                  this.formdisabled1 = false;
                  this.formdisabled2 = true;
                  this.formdisabled3 = true;
              } else {
                  this.formdisabled1 = false;
                  this.formdisabled2 = false;
                  this.formdisabled3 = false;
              }
          },
          deep: true,
      },
  },
  updated() {
      if (this.okFirstLoading) {
          let currentrow = "";
          let data = this.bactRuleData.filter((item) => item.rulecode == this.bactrulecode);
          if (data.length > 0) {
              currentrow = data[0];
          } else {
              //查询
              if (this.bactRuleData.length > 0) {
                  currentrow = this.$refs.xTable.getData(0);
              }
          }
          this.$nextTick(() => {
              if (!!currentrow) {
                  this.okFirstLoading = false;
                  this.hightLightRow(currentrow);
              } else {
                  this.hightLightRow(false);
              }
          });
      }
  },
  computed: {
      list() {
          //查询条件细菌
          let filterName = this.txtmedsearch.trim();
          if (filterName) {
              let rest = this.geramdata.filter((item) => {
                  return (item.data ? item.data.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.inputcode ? item.inputcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.display ? item.display.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
              });
              return rest;
          } else {
              return this.geramdata;
          }
      },
      labmedlist() {
          //抗生素规则
          let filterName = this.ruletxtmedsearch.trim();
          if (filterName) {
              let rest = this.labmedOption.filter((item) => {
                  return (item.medcode ? item.medcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.inputcode ? item.inputcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.medname ? item.medname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.medname_en ? item.medname_en.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
              });
              return rest;
          } else {
              return this.labmedOption;
          }
      },
      kseq() {
          //新增计算seq
          return (this.bactRuleData.length + 1) * 10;
      },
  },
  methods: {
      getMedResultList(){
          this.$ddldata.getMedResultList().then((data) =>{
              this.resultflagOption=data;
          })
      },
      //右上
      initdata() {
          this.bactRulecondData = [];
          this.condtypeInfo.forEach((item) => {
              let ruleconds = this.createRuleConds(item);
              this.bactRulecondData.push(ruleconds);
          }); //上
      }, //页面数据初始化
      btnQuery() {
          this.AddData = [];
          this.ModData = [];
          this.InitPage();
      },
      InitPage() {
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "getlist",
                      ...this.searchObj,
                  },
              })
              .then((res) => {
                  if (!!res) {
                      if (res.ruledt.length > 0) {
                          this.bactRuleData = res.ruledt;
                          this.okFirstLoading = true;
                      } else {
                          this.bactRuleData = [];
                          this.hightLightRow(false);
                      }

                      // if (this.bactRuleData.length == 0) this.hightLightRow(false)
                      // else this.hightLightRow(res.ruledt[0])
                  }
                  this.loading = false;
              })
              .catch((err) => {
                  this.loading = false;
              });
      }, //rule表
      activeMethod({ row }) {
          return false;
      }, //action表
      rxTable2Active({ row, column }) {
          if (column.property == "actions") {
              if (!!row.actionContent) {
                  return false;
              } else {
                  return true;
              }
          }
      },
      hasChange() {
          this.changeflag = true;
      }, //高亮行
      async hightLightRow(row) {
          if (row) {
              this.$refs.xTable.setCurrentRow(row);
              await this.querydetail(row);
          } else {
              this.$refs.xTable.setCurrentRow(null);
              this.bactRuleData = [];
              // this.bactRulecondData = []
              this.bactRuleActionData = [];
              this.fbact_rule = {};
              this.bact_rule = {};
          }
      },
      inputautofocus(element) {
          if (element == "popinput1") {
              this.$refs.popinput2.focus();
          } else if (element == "popinput2") {
              this.$refs.popinput2.blur();
              this.$refs.popinput3.focus();
          } else if (element == "popinput3") {
              this.$refs.popinput4.focus();
          } else if (element == "popinput4") {
              this.$refs.popinput5.$el.focus();
          } else if (element == "popinput5") {
              this.$refs.popinput6.focus();
          }
      },
      dialogEditruleSave() {
          if (!this.RowBactRule.rulecode) {
              alert("必须填写规则代码！");
              this.$refs.popinput1.focus();
              return false;
          }
          if (!this.RowBactRule.ruletype) {
              alert("必须选择规则类别！");
              this.$refs.popinput2.focus();
              return false;
          }
          if (!this.RowBactRule.rulename) {
              alert("必须填写规则名称！");
              this.$refs.popinput3.focus();
              return false;
          }
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "saverule",
                      isnew: this.actionindex,
                      rulecode: this.RowBactRule.rulecode,
                      ruletype: this.RowBactRule.ruletype,
                      rulename: this.RowBactRule.rulename,
                      rescomments: this.RowBactRule.rescomments,
                      validflag: this.RowBactRule.validflag,
                      seq: this.RowBactRule.seq,
                  },
              })
              .then((res) => {
                  if (res.errcode == "1") {
                      this.$message({
                          message: "操作成功！",
                          type: "success",
                          duration: "1000",
                          showClose: true,
                      });
                      this.bactrulecode = res.keyid;
                      if (this.actionindex == "A") {
                          if (this.AddData.indexOf(res.keyid) == -1) {
                              this.AddData.push(res.keyid);
                          }
                      } else {
                          if (this.ModData.indexOf(res.keyid) == -1) {
                              this.ModData.push(res.keyid);
                          }
                      }
                      this.InitPage();
                      this.dialogEditrule = false;
                  } else {
                      this.$message({
                          message: "操作失败！" + res.errmsg,
                          type: "error",
                          showClose: true,
                      });
                  }
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      //主表新增
      btnAdd() {
          // this.changeflag = true
          this.RowBactRule = { validflag: "1", seq: this.kseq };
          this.actionindex = "A";
          this.dialogEditrule = true;
          this.headtitle = "新增";
          this.disabled = false;
      }, //修改
      btnModify() {
          let row = this.$refs.xTable.getCurrentRow();
          this.RowBactRule = XEUtils.clone(row, true);
          this.actionindex = "M";
          this.dialogEditrule = true;
          this.headtitle = "修改";
          this.disabled = true;
      },
      btnDelete() {
          this.$confirm("您确定要删除这条数据吗？", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  this.startDelete();
              })
              .catch(() => {});
      }, //删除功能
      startDelete() {
          var delrow = this.$refs.xTable.getCurrentRow();
          if (delrow) {
              var alld = this.$refs.xTable.tableData;
              var rowindex = alld.indexOf(delrow);
              this.$refs.xTable.remove(delrow);
              this.$tool.request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "deleterule",
                      ruleInfo: this.bact_rule,
                  }
              })
              .then(response => {
                  this.bactRuleData.splice(rowindex, 1);
                  let havedata = this.$refs.xTable.tableData;
                  if (havedata.length > 0) {
                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                      let selectrow = havedata[rowindex];
                      this.bactrulecode = selectrow.rulecode;
                      this.querydetail(selectrow);
                      //this.hightLightRow(selectrow)
                  } else {
                      this.bactrulecode = "";
                      //this.hightLightRow(false)
                  }
              })
              .catch(e => {});
              // await this.btnSave().then(() => {
              //     this.bactRuleData.splice(rowindex, 1);
              //     let havedata = this.$refs.xTable.tableData;
              //     if (havedata.length > 0) {
              //         if (rowindex >= havedata.length) rowindex = havedata.length - 1;
              //         let selectrow = havedata[rowindex];
              //         this.bactrulecode = selectrow.rulecode;
              //         //this.hightLightRow(selectrow)
              //     } else {
              //         this.bactrulecode = "";
              //         //this.hightLightRow(false)
              //     }
              // });
          }
      }, //明细查询
      async querydetail(row) {
          try {
              this.actionindex = "M";
              this.pageinitloading = true;
              this.bactrulecode = row.rulecode;
              this.fbact_rule = row;
              this.bact_rule = XEUtils.clone(row, true);
              const res = await this.$tool.request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "getdetail",
                      rulecode: row.rulecode,
                  },
              });
              this.bactRulecondData = [];
              this.condtypeInfo.forEach((item) => {
                  let data = res.ruleconds.filter((m) => m.condtype == item.code);
                  if (data.length > 0) {
                      //有这个值
                      data[0].condtypename = item.name;
                      this.bactRulecondData.push(data[0]);
                  } else {
                      //没有这个值显示空
                      let ruleconds = this.createRuleConds(item);
                      this.bactRulecondData.push(ruleconds);
                  }
              }); //上
              this.bactRulecondData.sort((a, b) => {
                  return b.sortseq - a.sortseq;
              });
              // this.bactruleRow =this.bact_rule //res.rules //中
              console.log("res.ruleactions",res.ruleactions);
              this.bactRuleActionData = res.ruleactions; //下
              if (res.rules.length > 0) this.bact_rule = res.rules[0];
              this.pageinitloading = false;
          } catch (e) {
              this.pageinitloading = false;
              this.$alert(e);
          }
      },
      createRuleConds(item) {
          //条件序号后台生成
          let ruleconds = {
              rulecode: this.bact_rule.rulecode,
              condtype: item.code,
              condtypename: item.name,
              condvalue: "",
              operrator: "",
              condseq: item.seq,
              sortseq: item.sortseq,
          };
          return ruleconds;
      },
      //保存功能
      async btnSave() {
          try {
              let data = this.$refs.rxTable2.getRecordset();
              if (data.updateRecords.length > 0) {
                  data.updateRecords.forEach((item) => {
                      delete eval(item.cdata).actionContent;
                      delete eval(item.odata).actionContent;
                  });
              }
              const res = await this.$tool.request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "saveRecord",
                      // ruleInfo: this.$refs.xTable.getRecordset(),
                      ruleInfo: this.bact_rule,
                      ruleCondsInfo: this.$refs.rxTable1.getRecordset(),
                      ruleActioninfo: data,
                  },
              });
              if (res.errcode == "1") {
                  // this.fbact_rule = this.bact_rule;
                  this.$message.success("保存成功！");
                  this.changeflag = false;
                  this.InitPage();
              } else {
                  this.$message.error("保存失败！" + res.errmsg);
              }
          } catch (e) {
              this.$alert(e);
          }
      }, //取消
      btnClear() {
          this.$confirm("您确定要取消这次改动吗？", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  this.changeflag = false;
                  this.bact_rule = {...this.fbact_rule};
                  this.querydetail(this.bact_rule);
              })
              .catch(() => {});
      },
      rowClassName({ row, rowIndex }) {
          if (this.AddData.indexOf(row.rulecode) > -1) {
              return "row-new";
          }
          if (this.ModData.indexOf(row.rulecode) > -1) {
              return "row-modify";
          }
      }, //主表行选中
      async currentChange({ row }) {
          if (this.changeflag) {
              this.$refs.xTable.setCurrentRow(this.bact_rule);
              return false;
          } else {
              await this.querydetail(row);
          }
      }, //双击开窗功能
      opendialog({ row, column }) {
          if (column.property == "rescomments") {
              //主表说明字段
              this.dialogbactrule = XEUtils.clone(row, true);
              this.dialogComment = true;
          } else if (column.property == "condvaluename") {
              //右上表取值字段
              if (this.bactRuleData.length == 0) {
                  this.$alert("请新增细菌智能判断规则后再开窗！", "提示");
                  return false;
              }
              this.ruleconds = row;
              // console.log("opendialog", row);
              if (row.condtype == "pat_ageyear") {
                  // this.dialogpatage();
                  this.ageMultipleChk(row.condvalue, "condvalue", row.condtypename);
              // } else if (row.condtype == "bactcount") { // 菌落计数
              //     this.bactcountMultipleChk(row.condvalue, "condvalue", row.condtypename);
              } else {
                  let opt = row.condtype + "Option";
                  if (row.condtype == "otheritem") { // 其他项目，单选
                      // this.otheritem = row.condvalue;
                      // this.otheritemVisible = true;
                      opt = "rpt_itemcodeOption";
                  }
                  this.popMultipleChk(row.condvalue, "condvalue", this[opt], row.condtypename);
                  if (!row.condvalue) {
                      //如果没有取值，开窗默认满足
                      this.LIS848radio = 1;
                  } else {
                      if (!row.operrator) {
                          this.LIS848radio = -1;
                      } else {
                          this.LIS848radio = row.operrator == "<>" ? 0 : 1;
                      }
                  }
                  this.dialogCondvalue = true;
              }
          } else if (column.property == "condition1") {
              //右中表抗生素规则
              if (this.bactRuleData.length == 0) {
                  this.$alert("请新增细菌智能判断规则后再开窗！", "提示");
                  return false;
              }
              this.pbactrule = XEUtils.clone(this.bact_rule, true);
              this.dialoglabmedrule = true;
              this.ruletxtmedsearch = "";
              //this.HightlightPos(this.pbactrule.condition1)
          } else if (column.property == "condition2") { // 其他项目
              // this.pbactrule = XEUtils.clone(this.bact_rule, true);
              this.dialogtopdata = XEUtils.clone(this.bact_rule.condition2, true);
              this.dialogmiddledata = XEUtils.clone(this.bact_rule.condition2, true);
              this.outerVisible = true;
          } else if (column.property == "actionContent") {
              //右下表操作内容
              if (!!row.actions) {
                  this.pop_ruleaction = row;
                  if(row.flagformula != null && row.flagformula!='')
                  {
                      this.isFormula='1';
                  }else{
                      this.isFormula='0';
                  }
                  console.log("actitonrow",row);
                  this.dialogAction = true;
              } else {
                  this.$alert("未选择操作规则,不能开窗！", "提示");
              }
          }
      },
      specimenchange(code, name) {
          this.searchObj.specimen = code;
      }, //右上行选中
      bactRulecondChange({ row }) {
          this.bactRulecondRow = row;
      },
      //主表说明字段赋值
      dialogCommentSave() {
          this.bact_rule.rescomments = this.dialogbactrule.rescomments;
          this.dialogComment = false;
      },
      //右上年龄开窗
      dialogpatage() {
          this.$prompt("请输入年龄区间与单位，如1/12(y)-1(y),0.1(y)-2(y),10(y)-30(y)等", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              inputPattern: /[0-9./]+[\((]y[)\)]-[0-9./]+[\((]y[)\)]/,
              inputErrorMessage: "年龄区间格式不正确",
          })
              .then(({ value }) => {
                  this.closedialog(value, "condvalue", value, "1");
              })
              .catch(() => {
                  this.$message({
                      type: "info",
                      message: "取消输入",
                  });
              });
      },
      ageMultipleChk(e, fieldname, title) {
          console.log(e, fieldname, title)
          this.ageList = e.split(",");
          this.fieldname = fieldname;
          this.condTitle = title;
          this.multichktitle = title;
          this.dialogCondvalue = true;
      },
      //右上除年龄开窗赋值
      popMultipleChk(e, fieldname, option, title) {
          console.log(option)
          let temp = XEUtils.clone(option, true);
          // if (fieldname == "其他项目") temp = temp.filter()
          this.option1 = [];
          this.option2 = [];
          if (e != "") {
              let k = e.split(",");
              k.forEach((item) => {
                  let ndata = temp.find((m) => m.data == item);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              });
              temp.forEach((item) => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.fieldname = fieldname;
          this.multichktitle = title;
          this.condTitle = title;
          this.dialogCondvalue = true;
      },
      //右上闭窗赋值
      closedialog(value, name, textvalue, validflag) {
          console.log(value, name, this.ruleconds)
          if (value != "close") {
              let selrow = this.$refs.rxTable1.getCurrentRow();
              // this.ruleconds[name] = value;
              selrow[name] = value;
              // this.ruleconds[name + "name"] = textvalue;
              // this.ruleconds.validflag = validflag;
              selrow.validflag = validflag;
              if (validflag == "-1") {
                  // this.ruleconds.operrator = "";
                  selrow.operrator = "";
              } else {
                  // this.ruleconds.operrator = validflag == "1" ? "=" : "<>";
                  selrow.operrator = validflag == "1" ? "=" : "<>";
              }
              // console.log(this.bact_rule.rulecode)
              // this.ruleconds = this.bact_rule.rulecode;
              this.changeflag = true;
              // let selrow = this.$refs.rxTable1.getCurrentRow();
              selrow.condvaluename = value;
              // console.log(selrow)
              this.$forceUpdate();
          }
          this.dialogCondvalue = false;
      },
      // bactcountMultipleChk(e, fieldname, title) {
      //     console.log(e, fieldname, title)
      //     this.bactcount = e;
      //     this.fieldname = fieldname;
      //     this.condTitle = title;
      //     this.multichktitle = title;
      //     this.dialogCondvalue = true;
      // },
      // changeBactcount(action, bactcount, validflag) {
      //     if (action == "change") {
      //         this.closedialog(bactcount, "condvalue", bactcount, validflag);
      //     } else {
      //         this.dialogCondvalue = false;
      //     }
      // },
      changeAge(action, agestr) {
          console.log(agestr)
          if (action == "change") {
              this.closedialog(agestr, "condvalue", agestr, "1");
          } else {
              this.dialogCondvalue = false;
          }
      },
      changeRadMicVal(valuename) {
          if (valuename == 'radformula' && this.formdisabled2) return false;
          if (valuename == 'micformula' && this.formdisabled3) return false;
          this.chageName = valuename;
          this.formulatxtmedsearch = "";
          this.medformula = this.pop_ruleaction[valuename];
          if (valuename == 'micformula' && valuename) this.pop_ruleaction.medmethod = "";
          if (valuename == 'radformula' && valuename && !this.pop_ruleaction.medmethod) this.pop_ruleaction.medmethod = "KB";
          this.dialoglabmedformula = true;
           this.$nextTick(() => {
              this.$refs.formulacondition.$refs.textarea.focus();
           });
      },
      changeFlagVal(valuename){
          
          if(this.formdisabled1) return false;
          this.chageFlagName=valuename;
          this.flagformulatxtmedsearch="";
          this.flagformula=this.pop_ruleaction[valuename];

          this.dialoglabflagformula = true;
          this.$nextTick(() => {
              this.$refs.flagformulacondition.$refs.textarea.focus();
          });
      },
      changeMedmethod(e) {
          this.$forceUpdate();
      },
      dialogActionSave() {
          this.bact_ruleaction = this.pop_ruleaction;
          switch (this.bact_ruleaction.actions) {
              case "AR":
                  let code = this.pop_ruleaction.rescode;
                  let name = this.getname(code, this.rescodeOption, "resdict");
                  let alertstr = this.pop_ruleaction.alertflag == "1" ? "[危]" : "";
                  this.bact_ruleaction.actionContent = name + "(" + code + ")" + alertstr;
                  break;
              case "AC":
                  //选择时已赋值，这里不做处理。
              break;
              case "UC":
              case "CT":
              case "AA":
              case "IF":
              case "HM":
                  this.bact_ruleaction.actionContent = this.pop_ruleaction.txtresult;
                  break;
              case "UPM":
              case "BM":
              case "DM":
              case "RDM":
                  let code1 = this.pop_ruleaction.medcode;
                  let name1 = this.getname(code1, this.labmedOption, "labmed");
                  this.bact_ruleaction.actionContent = name1 + "(" + code1 + ")";
                  break;
              case "MM":
                  let code2 = this.pop_ruleaction.medcode;
                  let name2 = this.getname(code2, this.labmedOption);
                  let result_flag = this.pop_ruleaction.result_flag;
                  this.bact_ruleaction.actionContent = name2 + "(" + code2 + ")=" + result_flag;
                  break;
              case "AM":
                  let code3 = this.pop_ruleaction.medcode;
                  let name3 = this.getname(code3, this.labmedOption);
                  let result_flag3 = this.pop_ruleaction.result_flag;
                  let radformula = this.pop_ruleaction.radformula;
                  let micformula = this.pop_ruleaction.micformula;
                  let resultstr = (result_flag3 ? "=" + result_flag3 : '') + (radformula ? ',rad=' + radformula : '') + (micformula ? ',mic=' + micformula : '');
                  this.bact_ruleaction.actionContent = name3 + "(" + code3 + ")" + resultstr;
                  break;
          }
          this.dialogAction = false;
          this.hasChange();
      },
      getname(code, option, type) {
          let name = code;
          if (type == "labmed") {
              let data = option.filter((item) => item.medcode == code);
              if (data.length > 0) {
                  name = data[0].medname;
              }
          } else {
              let data = option.filter((item) => item.data == code);
              if (data.length > 0) {
                  name = data[0].display;
              }
          }
          return name;
      },
      //初始化选项数据
      async initOption() {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "getquery",
                  },
              });
              this.ruletypeOption = res.ruletype;
              this.actionsOption = res.actions;
              this.pat_typecodeOption = res.pattype;
              this.pat_sexOption = res.patsex;
              this.req_wardnoOption = res.wardOption;
              this.req_deptnoOption = res.deptOption;
              this.pat_diagOption = res.patdiag;
              this.rptunitidOption = res.rptunitOption;
              this.resdictOption = res.resdict; //耐药机制
              this.rescodeOption = res.rescode;
              this.rpt_itemcodeOption = res.rptitemcode;
              this.otheritemOption = res.otherrptitem;
              this.germkindOption = res.germkind;
              this.germgroupOption = res.germgroup;
              this.labmedOption = res.labmed;
              this.geramdata = this.germgramOption;
              this.specimenOption = res.specimen;
              this.purposeOption = res.purpose;
              // this.bactcountOption = res.bactcountOption;
              // this.geramdata = XEUtils.union(
              //   this.germgramOption,
              //   this.germkindOption,
              //   this.germgroupOption
              // )
          } catch (e) {
              this.$message.warning(e);
          }
      },
      btnDeleteDetail() {
          if (!this.bact_rule.rulecode) {
              return false;
          } else {
              var delrow = this.$refs.rxTable2.getCurrentRow();
              if (delrow) {
                  var alld = this.$refs.rxTable2.tableData;
                  var rowindex = alld.indexOf(delrow);
                  this.$refs.rxTable2.remove(delrow);
                  let havedata = this.$refs.rxTable2.tableData;
                  if (havedata.length > 0) {
                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                      let selectrow = havedata[rowindex];
                      this.$refs.rxTable2.setCurrentRow(selectrow);
                      this.changeflag = true;
                  }
              }
          }
      },
      btnAddDetail() {
          if (this.bactRuleData.length == 0) {
              this.$alert("请新增细菌智能判断规则后再新增！", "提示");
              return false;
          } else {
              let data = XEUtils.max(this.$refs.rxTable2.tableData, (item) => item.actionsseq);
              let kseq = 1;
              if (!!data) {
                  kseq = data.actionsseq + 1;
              }
              this.$refs.rxTable2
                  .insertAt(
                      {
                          rulecode: this.bact_rule.rulecode,
                          actionsseq: kseq,
                          actions: "",
                          validflag: "1",
                          rescode: "",
                          txtresult: "",
                          alertflag: "0",
                          medcode: "",
                          result_flag: "",
                      },
                      -1
                  )
                  .then(({ row }) => {
                      this.$refs.rxTable2.setCurrentRow(row);
                      this.$refs.rxTable2.scrollToRow(row);
                  });
              this.changeflag = true;
          }
      },
      rescodeChange(e) {
          let data = this.resdictOption.filter((item) => item.value == e);
          if (data.length > 0) {
              this.pop_ruleaction.alertflag = data[0].alertflag;
          } else {
              this.pop_ruleaction.alertflag = "0";
          }
      },
      germcommentchange(c,n){
          this.pop_ruleaction.actionContent=n;
          this.pop_ruleaction.txtresult=n;
      },
      GeramerChange({ row, column }) {
          this.geramerRow = row;
      },
      selectGeramer({ row }) {
          this.searchObj.germcode = row.data;
          this.dialogGeram = false;
      },
      confirmGeramer() {
          console.log(this.geramerRow);
          this.searchObj.germcode = this.geramerRow.data;
          this.dialogGeram = false;
      },
      clearGeramer() {
          this.searchObj.germcode = "";
          this.InitPage();
      },
      HightlightPos(myValue, tag) {
          var myField = {};
          if(tag == "formula"){
              myField = this.$refs.formulacondition.$refs.textarea;
          }else{
              myField = this.$refs.rulecondition.$refs.textarea;
          }
          if (myField.selectionStart || myField.selectionStart === 0) {
              var startPos = myField.selectionStart;
              var endPos = myField.selectionEnd;
              if(tag == "formula"){
                  this.medformula = myField.value.substring(0, startPos) + " " + myValue + " " + myField.value.substring(endPos, myField.value.length);
              }
              else{
                  this.pbactrule.condition1 = myField.value.substring(0, startPos) + " " + myValue + " " + myField.value.substring(endPos, myField.value.length);
              }
              this.$nextTick(() => {
                  myField.selectionStart = startPos + myValue.length + 2;
                  myField.selectionEnd = startPos + myValue.length + 2;
              }); // 这句是重点, 圈起来
              myField.focus();
              myField.setSelectionRange(myField, myField.selectionStart, myField.selectionEnd);
          } else {
              if(tag == "formula"){
                  this.medformula += " " + myValue + " ";
              }
              else{
                  this.pbactrule.condition1 += " " + myValue + " ";
              }
          }
      },
      FlagHightlightPos(myValue, tag) {
          var myField = {};
          myField = this.$refs.flagformulacondition.$refs.textarea;

          if (myField.selectionStart || myField.selectionStart === 0) {
              var startPos = myField.selectionStart;
              var endPos = myField.selectionEnd;
              this.flagformula = myField.value.substring(0, startPos) + " " + myValue + " " + myField.value.substring(endPos, myField.value.length);
              this.$nextTick(() => {
                  myField.selectionStart = startPos + myValue.length + 2;
                  myField.selectionEnd = startPos + myValue.length + 2;
              }); // 这句是重点, 圈起来
              myField.focus();
              myField.setSelectionRange(myField, myField.selectionStart, myField.selectionEnd);
          } else {
              this.flagformula += " " + myValue + " ";
          }
      },
      formulamedChangeEvent({ row }) {
          let formulatxt = "";
          if(this.formularadio == 3) //3 mic 2 rad
          {
              formulatxt = "[" + row.medcode + ":mic]";
          }
          else if(this.formularadio == 2){
              formulatxt = "[" + row.medcode + ":rad]";
          }
          
          this.HightlightPos(formulatxt, 'formula');
      },

      flagformulamedChangeEvent({ row }) {
          
          //this.HightlightPos(formulatxt, 'formula');
          this.anyonemedflag(row.medcode) ;
      },
      rulemedChangeEvent({ row }) {
          this.anyonemed(row.medcode);
      },
      operate(txtchar, type, tag) {
          let condition1 = "";
          if (type == "0") {
              condition1 += " " + txtchar;
          } else {
              condition1 += " " + "'" + txtchar + "'";
          }
          this.HightlightPos(condition1, tag);
      },
      flagoperate(txtchar, type, tag) {
          let condition1 = "";
          if (type == "0") {
              condition1 += " " + txtchar;
          } else {
              condition1 += " " + "'" + txtchar + "'";
          }
          this.FlagHightlightPos(condition1, tag);
      },
      anyonemed(txtchar) {
          const arrRuleRdo = ["RIS", "RESULT", "Rad", "Mic", "METHOD$DISK", "METHOD$MIC"];
          let ruleRdo = arrRuleRdo[this.ruleradio];
          let condition1 = "";
          if (this.ruleradio > 3) {
              //有$拼接
              let rulecond = ruleRdo.split("$");
              condition1 = " '[" + txtchar + ":" + rulecond[0] + ":0]' = '" + rulecond[1] + "'";
          } else {
              condition1 += " '[" + txtchar + ":" + ruleRdo + ":0]'";
          }
          this.HightlightPos(condition1);
      },
      anyonemedflag(txtchar) {
          const arrRuleRdo = ["RIS", "RESULT", "Rad", "Mic", "METHOD$DISK", "METHOD$MIC"];
          let ruleRdo = arrRuleRdo[this.flagformularadio];
          let condition1 = "";
          if (this.flagformularadio > 3) {
              //有$拼接
              let rulecond = ruleRdo.split("$");
              condition1 = " '[" + txtchar + ":" + rulecond[0] + "]' = '" + rulecond[1] + "'";
          } else {
              condition1 += " '[" + txtchar + ":" + ruleRdo + "]'";
          }
          this.FlagHightlightPos(condition1);
      },
      //验证抗生素公式表达式 新增抗生素设置mic或者rad值时
      async verifylanmedformula() {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "checkmicformula",
                      medformula: this.medformula,
                  },
              });
              if (res.msg != "") {
                  //验证失败
                  this.$alert(res.msg, "信息");
              } else {
                  //验证成功
                  this.pop_ruleaction[this.chageName] = this.medformula;
                  this.dialoglabmedformula = false;
                  this.chageName = "";
              }
          } catch (e) {
              this.$alert(e);
          }
      },

      //验证抗生素公式表达式 修改抗生素设置resuklt_flag值时
      async verifylanflagformula() {
          // try {
          //     const res = await this.$tool.request({
          //         url: "LIS/LIS8/LIS848",
          //         method: "post",
          //         data: {
          //             action: "checkmicformula",
          //             medformula: this.flagformula,
          //         },
          //     });
          //     if (res.msg != "") {
          //         //验证失败
          //         this.$alert(res.msg, "信息");
          //     } else {
          //         //验证成功
          //         this.pop_ruleaction[this.chageName] = this.flagformula;
          //         this.dialoglabflagformula = false;
          //         this.chageName = "";
          //     }
          // } catch (e) {
          //     this.$alert(e);
          // }

          this.pop_ruleaction[this.chageFlagName] = this.flagformula;
          this.dialoglabflagformula = false;
          this.chageFlagName = "";
      },
      //右中验证抗生素规则表达式
      async verifylanmedrule() {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "checkcondition1",
                      condition1: this.pbactrule.condition1,
                  },
              });
              if (res.msg != "") {
                  //验证失败
                  this.$alert(res.msg, "信息");
              } else {
                  //验证成功
                  //if (this.chageName != 'radformula' && this.chageName != 'micformula') {
                      this.bact_rule.condition1 = this.pbactrule.condition1;
                      this.hasChange();
                  // } else {
                  //     this.pop_ruleaction[this.chageName] = this.pbactrule.condition1;
                  // }
                  this.dialoglabmedrule = false;
                  this.chageName = "";
              }
          } catch (e) {
              this.$alert(e);
          }
      },
      //查询中细菌radio change事件
      geramradioChange() {
          if (this.geramradio == "1") {
              //细菌一级分类
              this.geramdata = XEUtils.clone(this.germgramOption, true);
          } else if (this.geramradio == "2") {
              //菌科
              this.geramdata = XEUtils.clone(this.germkindOption, true);
          } else if (this.geramradio == "3") {
              //菌属
              this.geramdata = XEUtils.clone(this.germgroupOption, true);
          } else {
              //细菌
              this.geramdata = XEUtils.clone(this.rpt_itemcodeOption, true);
          }
      },
      ExportCsv() {
          let p = { prgno: "LIS848" }
          this.$pub.commexport(this, p, `微生物智能专家规则库.dat`)
      },
      ImportCsv() {
          this.$refs["upload"].$refs["upload-inner"].handleClick();
      },
      // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
      beforeUploadFile(file) {
          let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
          let size = file.size / 1024 / 1024;
          if (extension !== "dat") {
              this.$notify.warning({
                  title: "警告",
                  message: `只能上传DAT(*dat)文件，且不超过10M`,
              });
          }
          if (size > 10) {
              this.$notify.warning({
                  title: "警告",
                  message: `文件大小不得超过10M`,
              });
          }
      },
      uploadOpt(content) {
          let formData = new FormData();
          formData.append("action", "BACCOMMOMUPLOAD");
          formData.append("file", content.file);
          this.$pub.uploadFileOpt(this, formData, "btnQuery");
      },
      // 文件状态改变时的钩子
      fileChange(file, fileList) {
          this.form.file = file.raw;
      },
      popcurrentChangeEvent({ row }) {
          //弹窗行选中事件
          let myValue = "[" + row.rpt_itemcode + "]";
          this.condition2HightlightPos(myValue);
          this.ConvertMiddatatoTopdata();
      },
      condition2HightlightPos(myValue) {
          var myField = document.getElementById("middiv"); //this.$refs.singleText;
          if (myField.selectionStart || myField.selectionStart === 0) {
              var startPos = myField.selectionStart;
              var endPos = myField.selectionEnd;
              this.dialogmiddledata = myField.value.substring(0, startPos) + " " + myValue + " " + myField.value.substring(endPos, myField.value.length);
              this.$nextTick(() => {
                  myField.selectionStart = startPos + myValue.length + 2;
                  myField.selectionEnd = startPos + myValue.length + 2;
              }); // 这句是重点, 圈起来
              myField.focus();
              myField.setSelectionRange(myField, myField.selectionStart, myField.selectionEnd);
          } else {
              this.dialogmiddledata += " " + myValue + " ";
          }
      },
      targetinput() {
          this.ConvertMiddatatoTopdata();
      },
      ConvertMiddatatoTopdata() {
          let middata = this.dialogmiddledata;
          let arr = middata.split(" ");
          let TopString = [];
          for (var i = 0, len = arr.length; i < len; i++) {
              let temp = "";
              let element = arr[i];
              if (element != "") {
                  if (element.indexOf("[") > -1 && element.indexOf("]") > -1) {
                      let tpel = this.getBracketStr(element);
                      let xtable = this.$refs.otheritemTable.tableData;
                      try {
                          xtable.forEach(element => {
                              let item = element.rpt_itemcode + "_" + element.itemcode_en;
                              if (item.indexOf(tpel) > -1) {
                                  let itemdata = item.split("_");
                                  let rpt_itemcode = itemdata[0];
                                  let itemcode_en = itemdata[1];
                                  temp = "[" + itemcode_en + "]";
                                  throw Error();
                              }
                          });
                      } catch (e) {}
                      if (temp == "") {
                          temp = element;
                      }
                  } else {
                      temp = element;
                  }
              } else {
                  temp = element;
              }
              TopString.push(temp);
          }
          this.dialogtopdata = TopString.join(" ");
      },
      rightEvent(event) {
          this.dialogx = false;
          if (event == "科室") {
              this.dialogtitle = "请选择科室";
              this.dataclass = "dept";
          } else if (event == "标本类型") {
              this.dialogtitle = "请选择标本类型";
              this.dataclass = "specimen";
          } else if (event == "诊断") {
              this.dialogtitle = "请选择诊断";
              this.dataclass = "diagnose";
          } else if (event == "诊断ICD10") {
              this.dialogtitle = "请选择诊断ICD10";
              this.dataclass = "diagnose";
          } else {
          }
          this.dialogx = true;
          this.dialogTableVisible = true;
      },
      cancelinnerdialog() {
          this.dialogTableVisible = false;
          this.dialogx = false;
      },
      popcomchange(c, v) {
          //"选择后code", c//"选择后name", v
          this.dialogx = false;
          if (this.dialogmiddledata != "") {
              //如果是新增
              var myValue = "";
              if (this.dataclass == "dept" || this.dataclass == "specimen") {
                  myValue = '"' + c + '"';
              } else {
                  myValue = '"' + v + '"';
              }
              this.condition2HightlightPos(myValue);
          } else {
              //修改
              if (this.dataclass == "dept" || this.dataclass == "specimen") {
                  this.dialogtopdata += " " + '"' + c + '"' + " ";
                  this.dialogmiddledata += " " + '"' + c + '"' + " ";
              } else {
                  this.dialogtopdata += " " + '"' + v + '"' + " ";
                  this.dialogmiddledata += " " + '"' + v + '"' + " ";
              }
          }
          this.ConvertMiddatatoTopdata();
          this.dialogTableVisible = false;
      },
      getBracketStr(text) {
          let result = "";
          let regex = /\[(.+?)\]/g;
          let options = text.match(regex);
          let option = options[0];
          result = option.substring(1, option.length - 1);
          return result;
      },
      otherItemOperate(text, type) {
          //按钮选中
          if (type == "1") {
              this.tempvarible = " " + text + " ";
          } else if (type == "2") {
              this.tempvarible = " " + '"' + "[" + text + "]" + '"' + " ";
          } else {
              this.tempvarible = " " + "[" + text + "]" + " ";
          }
          if (this.dialogmiddledata != "") {
              //如果是新增
              if (type == "1") {
                  this.tempvarible = text;
              } else if (type == "2") {
                  this.tempvarible = '"' + "[" + text + "]" + '"';
              } else {
                  this.tempvarible = "[" + text + "]";
              }
              var myValue = this.tempvarible;
              this.condition2HightlightPos(myValue);
          } else {
              this.dialogtopdata += this.tempvarible;
              this.dialogmiddledata += this.tempvarible;
          }
          this.ConvertMiddatatoTopdata();
          const h = this.$createElement;
          let k = false;
          let popstr = "";
          if (text == "性别") {
              popstr = "1：男 2：女";
              k = true;
          } else if (text == "病人类型") {
              popstr = "1:门诊，2：急诊，3：住院，4：体检，其他请查看字典中的设定";
              k = true;
          } else if (text == "科室") {
              popstr = "鼠标右键点击可选择 科室代码";
              k = true;
          } else if (text == "标本类型") {
              popstr = "鼠标右键点击可选择 标本类型";
              k = true;
          } else if (text == "诊断") {
              popstr = "鼠标右键点击可选择 诊断文字";
              k = true;
          } else if (text == "诊断ICD10") {
              popstr = "鼠标右键点击可选择 诊断ICD10";
              k = true;
          } else {
          }
          if (k) {
              this.$message({
                  message: h("p", null, [h("span", null, text), h("i", { style: "color: teal" }, popstr)])
              });
          }
      },
      //右中验证其他项目表达式
      async verifyCondition2() {
          if (this.dialogmiddledata) {
              this.$tool.request({
                  url: "LIS/LIS8/LIS848",
                  method: "post",
                  data: {
                      action: "checkcondition2",
                      checkrules: this.dialogmiddledata,
                  },
              }).then(res => {
                  if (res.msg != "") {
                      //验证失败
                      this.$alert(res.msg, "信息");
                  } else {
                      //验证成功
                      this.bact_rule.condition2 = this.dialogmiddledata;
                      this.outerVisible = false;
                      this.hasChange();
                  }
              }).catch(e => {
                  this.$alert(e);
              });
          } else {
              if (this.bact_rule.condition2 != this.dialogmiddledata) this.hasChange();
              this.bact_rule.condition2 = this.dialogmiddledata;
              this.outerVisible = false;
          }
      },
  },
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 65px;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 70px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}
.rolecond-content {
  width:100%;
  height: calc(100% - 275px);
}
.otheritem-content {
  margin-top: 5px;
  height: 50px;
}
.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 505px;
  overflow: auto;
}

.middle-right {
  position: absolute;
  height: 100%;
  width: 500px;
  right: 0px;
}

/deep/ tr.vxe-body--row.row-modify {
  color: blue;
}
/deep/ tr.vxe-body--row.row-new {
  color: #cc6600;
}
.table1style tr td {
  padding: 1px 2px 1px 5px;
}
.table2style tr td {
  padding: 2px;
}
/deep/ .el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}
/deep/.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: blue;
}

/deep/ .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner + .el-input.is-disabled .el-input__inner {
  background-color: #ffffff !important;
}
.pagetop-p {
  width: 100%;
  height: 70px;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  position: absolute;
  z-index: 99;
}

.pagecenter-p {
  position: absolute;
  top: 72px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center-p {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 265px;
  overflow: auto;
}

.middle-right-p {
  position: absolute;
  height: 100%;
  width: 260px;
  right: 0px;
  border: 1px solid #ccc;
}
.upload-button {
  height: 24px;
  margin: 0 10px;
  display: none;
}
.upload-button div {
  height: 24px;
}
</style>